<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/base.jsp"%>
<%@ include file="/module/taglibs.jsp"%>
<%@ include file="/module/nocache.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>栏目管理</title>
<%@ include file="/module/js.jsp"%>
	<script type="text/javascript">
			$(document)
					.ready(
							function() {
								$('#dg').datagrid({
									onClickRow: function (rowIndex, rowData) {
										alert(1);
						                $(this).datagrid('unselectRow', rowIndex);
						         },
								/* onSortColumn :function(sort,order){
								   var _sort=sort;
								   var _order=order;
								   var options=$('#dg').datagrid('getPager').data("pagination").options;
								   var page=options.pageNumber;
								   var pageSize=options.pageSize;
								   //alert(page+"==="+pageSize);
								   window.setTimeout(function(){
									   $.post("${basePath}/demo/demoList",{orderFlag:_order,orderField:_sort},
												function(data){
												  $('#dg').datagrid("loadData",data); 
											   });
											   },100);  
								   },*/
								   rowStyler: function(index,row){
								   }
								});
								//查询
								$('#btnQuery')
										.click(
												function() {
													$('#dg').datagrid('load',{
														bjmc: $('#bjmc').val()
													});
												});
								//新增
								$('#btnAdd')
										.click(
												function() {
													document.demoForm.action = "${basePath}/demo/addStudentDemoForward";
													document.demoForm.submit();
												});

								//删除
								$('#btnDelete')
										.click(
												function() {
													var itemList = $("#dg");
											    	var sels = $("#dg").datagrid("getSelections");
											    	var idList = new Array();
											    	var count = 0;
											    	for(var i in sels){
											    		idList.push(sels[i].id);
											    		count++;
											    	}
											    	if (count == 0) {
														alert("请选择一条记录 ");
														return false;
													}
													document.demoForm.action = "${basePath}/demo/deletStudentDemo";
													document.demoForm.submit();
												});
								$("#btnImport").click(
										function(){
											$('#importDiv').dialog('open');
									});
							
							     //导入	
								$("#importDiv").dialog({
								    bgiframe: true,
									modal: true,
									draggable:false,
									resizable:false,
									title:'xxxx基本信息导入',
									autoOpen:false,
									width:400,
									height:300,
									buttons:{
									     '取消':function() {
									     	$(this).dialog('close');
									     },
										'导入': function() {
											var val = document.getElementById("studentDemoFile").value;
											if(val.indexOf(".")>0 && val.lastIndexOf(".")>0 && val.substring(val.lastIndexOf("."),val.length) == ".xls"){
												$("#processMessage").css("display","");
										       	$("#uploadForm").attr("action","${basePath}/demo/importStudentDemo");
												$("#uploadForm").submit();
										    }else{
										    	layer.alert("您输入的文件格式不正确！\n合法格式：*.xls", {icon: 3});
										    	return;
										    }
										}
									}
								});
							     
								$('#btnExport').on('click', function(){
								   layer.confirm("您确定要下载吗?", {icon: 3, title:'提示',skin:'layer-ext-moon'}, function(index){
									  // $("#uploadForm").attr("action","${basePath}/demo/exportStudentDemo");
											document.demoForm.action = "${basePath}/demo/exportStudentDemo";
											document.demoForm.submit();
											//$("#uploadForm").submit();	
				               		 });
								});
								
								

							});
// 			function sortByColumn(_orderFiled) {
// 				var _actionPath = '${basePath}/demo/demoList';
// 				_form = document.demoForm;
// 				sortOrderByColumn(_orderFiled, "${orderFlag}", _form,
// 						_actionPath);
// 			}
			
// 			 function getSelectionsIds(){
// 			    	var itemList = $("#dg");
// 			    	var sels = $("#dg").datagrid("getSelections");
// 			    	var ids = [];
// 			    	for(var i in sels){
// 			    		alert(sels[i].id);
// 			    		ids.push(sels[i].id);
// 			    	}
// 			    	ids = ids.join(",");
// 			    	return ids;
// 			    }

	   function formater(value, row, index) {
	       return "<a href='${basePath}/demo/modfityStudentDemoForward?id=" + row.id + "'>" + value + "</a>";
	  }
 
	    //下载模板
		function downLoadFileTemplete(){
		document.getElementById("myiframe").src="${basePath}/servlet/DownLoadServlet?chinesefileName=学生信息&filename=studentDemo.xls&dir=/execlFile/";
	 }

		</script>
</head>
<body >
	<form action="#" name="demoForm" id="demoForm" method="post">
		<table cellpadding="1" cellspacing="1" border="0">
			<tr>
				<td><input type="button" id="btnQuery" autocomplete="off"  value="查询"
					class="inputButton" /></td>
				<kl:permission permisstionList="${permisstionList}"
						currentUser="${_login_console_user}" 
						currentCatalogId="<%=CatalogUtils.getCatalogId(\"catalog0\")%>" key="add"> 
				<td><input type="button" id="btnAdd" value="添 加" autocomplete="off" 
					class="inputButton" /></td>
				<td><input type="button" id="btnImport" autocomplete="off"  value="导入"
					class="inputButton" /></td>
			</kl:permission> 
			<kl:permission permisstionList="${permisstionList}"
						currentUser="${_login_console_user}"
 						currentCatalogId="<%=CatalogUtils.getCatalogId(\"catalog0\")%>" key="delete"> 
				<td><input type="button" id="btnDelete" value="删除"
					class="inputButton" /></td>
			 </kl:permission> 
			 	<td><input type="button" id="btnExport" value="导出"
					class="inputButton" /></td>
			</tr>
		</table>
		<table cellpadding="1" cellspacing="1">
			<tr>
				<td>年级：</td>
				<td><select id="grade" name="greade" class="selectList">
						<option value="">全部</option>
						<option value="2018">2018</option>
						<option value="2017">2017</option>
						<option value="2016">2016</option>
						<option value="2015">2015</option>
				</select></td>
				<td>院系：</td>
				<td><select id="yx" name="yx" class="selectList">
						<option value="">全部</option>
						<option value="1">院系A</option>
						<option value="2">院系A</option>
						<option value="3">院系A</option>
				</select></td>
				<td>专业：</td>
				<td><select id="specname" name="specname" class="selectList">
						<option value="">全部</option>
						<option value="001">计算机应用</option>
						<option value="002">计算机信息管理</option>
				</select></td>
				<td>班级：</td>
				<td><input type="text" id="bjmc" name="bjmc" value="" class="inputText" /></td>
			</tr>
		</table>
		<br/>
		<!-- 需要序号：增加 rownumbers:true-->
		<table id="dg"  style="width: 975px;"
		data-options="pagination:true,collapsible:true,url:'${basePath}/demo/demoList',method:'post',remoteSort:true">
		<thead>
			<tr>
				<th data-options="field:'ck',checkbox:true,width:120,align:'center'"></th>
				<th data-options="field:'name',sortable:true,nowrap:true,width:300,align:'center',formatter: formater">名称</th>
				<th data-options="field:'age',nowrap:true,width:300,align:'center',sortable:true">年龄</th>
				<th data-options="field:'score',nowrap:true,width:300,align:'center',sortable:true">成绩</th>
<!-- 				<th -->
<!-- 					data-options="field:'createTime',align:'center',formatter:formatDate">写作时间</th> -->
<!-- 				<th data-options="field:'name',align:'center'">作者</th> -->
			</tr>
		</thead>
	</table>

	<div id="importDiv" style="display: none;text-align:center;padding-top: 35px;height: 300px;">
			<div id="processMessage" style="display: none;"><img src="${basePath}/img/ajax.gif"/>数据正在导入中，请耐心等候...</div>
			<div style="margin-top: 0px;">
				<form action="#" name="uploadForm" id="uploadForm" method="post" enctype="multipart/form-data">
				<table cellpadding="0" cellspacing="0" border="0">
				<tr>
				<td>请选择导入方式：<input type="radio" id="exportFlag" name="exportFlag" value="1" checked="checked"/>添加&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" id="exportFlag" name="exportFlag" value="2"/>更新</td>
				</tr>
				<tr style="height: 50px;">
				<td><input type="file" name="studentDemoFile" id="studentDemoFile" style="width: 350px;" onkeydown="return false;" oncontextmenu="window.event.returnValue=false" /></td>
				</tr>
				<tr style="height: 50px;">
				<td colspan="1"><a href="javascript:downLoadFileTemplete();"  style="color: red;text-decoration: underline;">下载模板</a></td>
				</tr>
				</table>
				</form>
			</div>
		   <br/>
			<br>
			<IFRAME ID=myiframe NAME=myiframe SRC="#" WIDTH="0" HEIGHT="0" ></IFRAME>
		</div>
	
	
	</form>
</body>
</html>
